Imports OMANE.Common.UI
Imports System.Collections.ObjectModel
Imports System.Windows
Imports Infragistics.Windows.Chart
Imports System.Windows.Controls
Imports System.ComponentModel
Imports System.Xml.Serialization
Imports OMANE.Modules.Indicateurs.Zones


Namespace Services


    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    <Common.ServiceInfo(LifeTime:=Common.ServiceLifetime.Singleton)>
    Public Class ZoneProviderService
        Implements IZoneProviderService

        Friend ZoneTypes As New List(Of ZoneType)

        ''' <summary>
        ''' 
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub Initialize() Implements Common.IService.Initialize
            RegisterZoneType(GetType(VMNumberZone))
            RegisterZoneType(GetType(VMPieZone))
            RegisterZoneType(GetType(VMBarZone))
            RegisterZoneType(GetType(VMHistogramZone))
            RegisterZoneType(GetType(VMHistogramZoneSimple))
            RegisterZoneType(GetType(VMLineZone))
            RegisterZoneType(GetType(VMSplineZone))
            RegisterZoneType(GetType(VMGaugeZone))
            RegisterZoneType(GetType(TextZone))
            RegisterZoneType(GetType(VMFormatedTextZone))
            RegisterZoneType(GetType(Facades.XamChartFacade))
            RegisterZoneType(GetType(Facades.ColumnBarChartFacade))
            RegisterZoneType(GetType(Facades.PieChartFacade))
            RegisterZoneType(GetType(Facades.ContinuousFacade))
            RegisterZoneType(GetType(Facades.XamRadialGaugeFacade))
            RegisterZoneType(GetType(Facades.XamDataChartFacade))
        End Sub

        ''' <summary>
        ''' 
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub RegisterZoneType(ByVal ParamArray types() As System.Type) Implements IZoneProviderService.RegisterZoneType
            If types Is Nothing Then Return
            For Each e In types
                If e.IsClass And Not e.IsAbstract And Not e.IsGenericType Then
                    Dim attr = e.GetCustomAttributes(GetType(EditableZoneAttribute), False)
                    If attr IsNot Nothing Then
                        If attr.Length > 0 Then
                            Dim zt As New ZoneType(e, attr(0))
                            If Not ZoneTypes.Contains(zt, ZoneType.TypeComparer) Then
                                ZoneTypes.Add(zt)

                            End If
                        End If
                    End If
                End If
            Next
        End Sub

#Region "IDisposable Support"
        Private disposedValue As Boolean ' Pour détecter les appels redondants

        ''' <summary>
        ''' 
        ''' </summary>
        ''' <remarks></remarks>
        Protected Overridable Sub Dispose(ByVal disposing As Boolean)
            If Not Me.disposedValue Then
                If disposing Then
                    ' TODO: supprimez l'état managé (objets managés).
                End If

                ' TODO: libérez les ressources non managées (objets non managés) et substituez la méthode Finalize() ci-dessous.
                ' TODO: définissez les champs volumineux à null.
            End If
            Me.disposedValue = True
        End Sub

        ' TODO: substituez Finalize() uniquement si Dispose(ByVal disposing As Boolean) ci-dessus comporte du code permettant de libérer des ressources non managées.
        'Protected Overrides Sub Finalize()
        '    ' Ne modifiez pas ce code. Ajoutez du code de nettoyage dans Dispose(ByVal disposing As Boolean) ci-dessus.
        '    Dispose(False)
        '    MyBase.Finalize()
        'End Sub

        ''' <summary>
        ''' 
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub Dispose() Implements IDisposable.Dispose
            ' Ne modifiez pas ce code. Ajoutez du code de nettoyage dans Dispose(ByVal disposing As Boolean) ci-dessus.
            Dispose(True)
            GC.SuppressFinalize(Me)
        End Sub
#End Region

    End Class
End Namespace